﻿<UserControl x:Class="Notoric.View.Music.CWNotation.Controls.DynamicsProgressMark"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:my="clr-namespace:Notoric.View.Music.CWNotation.Controls"
             DataContextChanged="UserControl_DataContextChanged"
             MouseLeftButtonDown="UserControl_MouseLeftButtonDown"
             Cursor="Hand">
    <UserControl.ContextMenu>
        <ContextMenu>
            <MenuItem x:Name="menu_Crescendo" Header="crescendo" FontFamily="Georgia" FontSize="10" FontStyle="Italic" Click="menu_ProgressType_Click"/>
            <MenuItem x:Name="menu_Decrescendo" Header="decrescendo" FontFamily="Georgia" FontSize="10" FontStyle="Italic" Click="menu_ProgressType_Click"/>
            <MenuItem x:Name="menu_Diminuendo" Header="diminuendo" FontFamily="Georgia" FontSize="10" FontStyle="Italic" Click="menu_ProgressType_Click"/>
            <Separator/>
            <MenuItem x:Name="menu_Abbreviated" Header="Abbreviated" IsCheckable="True" IsChecked="{Binding Abbreviated, Mode=OneWay}"
                      Checked="menu_Abbreviated_Checked" Unchecked="menu_Abbreviated_Unchecked"/>
            <Separator/>
            <MenuItem x:Name="menu_Visualization" Header="Visualization">
                <MenuItem x:Name="menu_VisualizationText" Header="Textual" IsCheckable="True" Click="menu_VisualizationText_Click"/>
                <MenuItem x:Name="menu_VisualizationHairpin" Header="Hairpin" IsCheckable="True" Click="menu_VisualizationHairpin_Click"/>
            </MenuItem>
            <Separator/>
            <MenuItem x:Name="menu_Expression" Header="Expression">
                <MenuItem x:Name="menu_PocoAPoco" Header="poco a poco" FontFamily="Georgia" FontSize="10" FontStyle="Italic" Click="menu_Expression_Click" Tag="poco a poco"/>
                <MenuItem x:Name="menu_Espressivo" Header="espressivo" FontFamily="Georgia" FontSize="10" FontStyle="Italic" Click="menu_Expression_Click" Tag="espressivo"/>
                <MenuItem x:Name="menu_Marcato" Header="marcato" FontFamily="Georgia" FontSize="10" FontStyle="Italic" Click="menu_Expression_Click" Tag="marcato"/>
                <MenuItem x:Name="menu_Dolce" Header="dolce" FontFamily="Georgia" FontSize="10" FontStyle="Italic" Click="menu_Expression_Click" Tag="dolce"/>
                <MenuItem x:Name="menu_Legato" Header="legato" FontFamily="Georgia" FontSize="10" FontStyle="Italic" Click="menu_Expression_Click" Tag="legato"/>
                <MenuItem x:Name="menu_Estinto" Header="estinto" FontFamily="Georgia" FontSize="10" FontStyle="Italic" Click="menu_Expression_Click" Tag="estinto"/>
                <MenuItem x:Name="menu_Smorzando" Header="smorzando" FontFamily="Georgia" FontSize="10" FontStyle="Italic" Click="menu_Expression_Click" Tag="smorzando"/>
                <MenuItem x:Name="menu_Perdendosi" Header="perdendosi" FontFamily="Georgia" FontSize="10" FontStyle="Italic" Click="menu_Expression_Click" Tag="perdendosi"/>
                <MenuItem x:Name="menu_Simile" Header="simile" FontFamily="Georgia" FontSize="10" FontStyle="Italic" Click="menu_Expression_Click" Tag="simile"/>
                <MenuItem x:Name="menu_MaNonTroppo" Header="ma non troppo" FontFamily="Georgia" FontSize="10" FontStyle="Italic" Click="menu_Expression_Click" Tag="ma non troppo"/>
                <MenuItem x:Name="menu_NonTanto" Header="non tanto" FontFamily="Georgia" FontSize="10" FontStyle="Italic" Click="menu_Expression_Click" Tag="non tanto"/>
                <MenuItem x:Name="menu_UnPoco" Header="un poco" FontFamily="Georgia" FontSize="10" FontStyle="Italic" Click="menu_Expression_Click" Tag="un poco"/>
                <MenuItem x:Name="menu_AdLibitum" Header="ad libitum" FontFamily="Georgia" FontSize="10" FontStyle="Italic" Click="menu_Expression_Click" Tag="ad libitum"/>
                <Separator/>
                <MenuItem x:Name="menu_ClearExpression" Header="Clear Expression" Click="menu_Expression_Click" Tag=""/>
            </MenuItem>
        </ContextMenu>
    </UserControl.ContextMenu>
    <UserControl.Resources>
        <Style x:Key="ThumbStyle" TargetType="{x:Type Thumb}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Thumb}">
                        <Grid x:Name="PART_Content" Visibility="Collapsed">
                            <Ellipse Height="6" Width="6" Margin="-3 -3 0 0">
                                <Ellipse.Fill>
                                    <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                        <GradientBrush.GradientStops>
                                            <GradientStopCollection>
                                                <GradientStop Color="#CCC" Offset="0.0"/>
                                                <GradientStop Color="#AAA" Offset="1.0"/>
                                            </GradientStopCollection>
                                        </GradientBrush.GradientStops>
                                    </LinearGradientBrush>
                                </Ellipse.Fill>
                            </Ellipse>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <DataTrigger Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=FixedPage}}" Value="{x:Null}">
                                <Setter TargetName="PART_Content" Property="Visibility" Value="Visible"/>
                            </DataTrigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    <Canvas>
        <Path x:Name="PART_Hairpin" Stroke="Black" StrokeThickness="0.02cm">
            <Path.Data>
                <PathGeometry>
                    <PathGeometry.Figures>
                        <PathFigure StartPoint="{Binding HairpinPoint, Mode=OneWay}">
                            <LineSegment Point="{Binding HairpinEnd1, Mode=OneWay}"/>
                        </PathFigure>
                        <PathFigure StartPoint="{Binding HairpinPoint, Mode=OneWay}">
                            <LineSegment Point="{Binding HairpinEnd2, Mode=OneWay}"/>
                        </PathFigure>
                    </PathGeometry.Figures>
                </PathGeometry>
            </Path.Data>
        </Path>
        <Thumb x:Name="PART_PointThumb" Style="{StaticResource ThumbStyle}" Canvas.Left="{Binding HairpinPoint.X, Mode=OneWay}" Canvas.Top="{Binding HairpinPoint.Y, Mode=OneWay}"
               DragDelta="PART_PointThumb_DragDelta" DragCompleted="PART_PointThumb_DragCompleted" Cursor="Hand"/>
        <Thumb x:Name="PART_EndsThumb" Style="{StaticResource ThumbStyle}" Canvas.Left="{Binding HairpinEnd1.X, Mode=OneWay}" Canvas.Top="{Binding HairpinPoint.Y, Mode=OneWay}"
               DragDelta="PART_EndsThumb_DragDelta" DragCompleted="PART_EndsThumb_DragCompleted" Cursor="Hand"/>
        <my:PositionableDragThumb Canvas.Left="{Binding Position.X, Mode=OneWay}" Canvas.Top="{Binding Position.Y, Mode=OneWay}" x:Name="PART_TextThumb" Cursor="Hand">
            <my:PositionableDragThumb.Template>
                <ControlTemplate TargetType="{x:Type my:PositionableDragThumb}">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock x:Name="PART_Text" Text="{Binding Text, Mode=OneWay}" FontFamily="Georgia" FontSize="10" FontStyle="Italic"/>
                        <TextBlock x:Name="PART_Expression" Text="{Binding Expression, Mode=OneWay}" FontFamily="Georgia" FontSize="10" FontStyle="Italic" Margin="4 0 0 0"/>
                    </StackPanel>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="PART_Expression" Property="Foreground" Value="Blue"/>
                            <Setter TargetName="PART_Text" Property="Foreground" Value="Blue"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </my:PositionableDragThumb.Template>
        </my:PositionableDragThumb>
    </Canvas>
</UserControl>
